package com.sky.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface WorkspaceMapper {

    /**
     * 查询新增用户数
     * @param begin
     * @param end
     * @return
     */
    @Select("select count(*) from user where create_time between #{begin} and #{end}")
    Integer getNewUsers(LocalDateTime begin, LocalDateTime end);

    /**
     * 根据时间范围查询营业额
     * @param begin
     * @param end
     * @param status
     * @return
     */
    @Select("select sum(amount) from orders where order_time between #{begin} and #{end} and status = #{status}")
    Double getTurnover(LocalDateTime begin, LocalDateTime end, Integer status);

    /**
     * 根据时间范围查询有效订单数
     * @param begin
     * @param end
     * @param status
     * @return
     */
    @Select("select count(*) from orders where order_time between #{begin} and #{end} and status = #{status}")
    Integer getOrderCountByStatus(LocalDateTime begin, LocalDateTime end, Integer status);

    /**
     * 根据时间范围查询订单总数
     * @param begin
     * @param end
     * @return
     */
    @Select("select count(*) from orders where order_time between #{begin} and #{end}")
    Integer getTotalOrderCount(LocalDateTime begin, LocalDateTime end);

    /**
     * 根据状态查询套餐总数
     * @param status
     * @return
     */
    @Select("select count(*) from setmeal where status = #{status}")
    Integer countSetmealByStatus(Integer status);

    /**
     * 根据状态查询菜品总数
     * @param status
     * @return
     */
    @Select("select count(*) from dish where status = #{status}")
    Integer countDishByStatus(Integer status);
}
